The technology of detecting link faults quickly is more and more important in the network applications. Through such a technology, the network system can discover faults quickly and take the corresponding actions after the link fails. Currently, some transmission media are capable of detecting faults quickly, but other transmission media (such as Ethernet) are not capable of such a function. Therefore, auxiliary detection is generally performed through a Hello mechanism (generally applied to routing protocol). However, the Hello mechanism discovers the fault after at least one second after the fault occurs. On a high-speed link, such a long period of fault detection leads to loss of plenty of data. Therefore, a detection mechanism which is faster and independent of the routing protocol needs to be introduced. Therefore, a BFD protocol is put forward in this field.
The BFD protocol is designed for end-to-end link detection, and the detection takes only microseconds. In the detection, a session is set up between both sides through negotiation first. After the session is set up, both sides send BFD packets to the peer periodically, and detect the state of the link that conveys the BFD packet. If one side receives no BFD packet from the peer within a preset period, the session state changes to “Down”, indicating that the link that conveys the BFD packet fails. The BFD packets here refer to various transmission protocol packets of the BFD-related content. In other words, the payload of the protocol packets carries the BFD-related content.
While BFD packets are exchanged between both sides, both sides can negotiate the frequency of sending the BFD packets. If the frequency is higher, the fault detection is faster. In an Internet Protocol Version 4 (IPv4) or Internet Protocol Version 6 (IPv6) network, the format of an encapsulated BFD packet is User Datagram Protocol (UDP)—Internet Protocol (IP). If the session between both sides do not pass through any layer-3 devices, the session is called a single-hop session, and if the session between both sides passes through at least one layer-3 device, the session is called a multi-hop session.
In a network system, many sessions may exist. For identification, the network system needs to allocate a non-zero unique session Identifier (ID) to each session in the network system. For the same session, it is possible that the session ID allocated by one side to the session is different from the session ID allocated by the other side to the session. Therefore, in the negotiation stage of setting up the session, both sides need to learn the session ID allocated by the peer to the session, and input the session ID allocated by the local side and the session ID allocated by the peer to the session into the BFD packet when sending the BFD packet. In this way, after receiving the BFD packet, the peer can resolve the BFD packet to obtain the session ID in the BFD packet correctly, and send the session ID to the corresponding session.
In the initialization negotiation, the sender of the BFD packet (source) has not learned the session ID allocated by the peer (destination) to the session. When sending a BFD packet to the destination, the source inputs 0 as a session ID allocated by the destination to the session in the BFD packet, and such a BFD packet is called an initial BFD packet. After receiving the initial BFD packet, the destination needs to determine the session corresponding to the packet according to other information (such as source IP address, destination IP address, and ingress interface information of the BFD packet) before the destination can learn the session ID allocated by the source to the session. It is the same with the process of sending the initial BFD packet from the destination to the source. The session can be set up only after both sides learn the session ID allocated by the peer to the session. In the process of developing the present invention, the inventor finds that: If multiple links exists between both sides, after the destination receives the initial BFD packet, the destination is unable to know the session corresponding to the initial BFD packet because the destination session ID in the initial BFD packet is 0, and the session setup fails.
Moreover, if multiple links exist between both sides and multiple multi-hop sessions are set up between both sides, when BFD packets are exchanged between both sides, the BFD packet carries only the source IP address, destination IP address, and the session ID allocated by the source to the session, but the session ID allocated by the destination to the session is 0 and multiple sessions are set up between both sides. In this way, when sending or forwarding the BFD packet, the source or the intermediate layer-3 device may select any normal link, and the BFD packet can still arrive at the destination even if a link between both sides fails. After receiving the BFD packet, the destination is unable to know the session corresponding to the BFD packet, or unable to know the link to be detected through this BFD packet, and the fault detection fails.